<template>
  <div>
    <div class="headBox">
      <img class="hearbg" src="@/assets/taskbg.png" alt="" />
      <img class="logobg" src="@/assets/logobg.png" alt="" />

      <img class="logo" src="@/assets/logo.png" alt="" />
      <div class="task">
        <span :class="{ active: task_id == task.id }" @click="change(task.id)"
        v-for="task in task_list"
          >{{task.task_name}} <img src="@/assets/taskLine.png" alt="" />
        </span>
      </div>
    </div>
    <div class="menu">
      <img class="left" src="@/assets/menu-left.png" alt="" />
      <div class="right">
        <router-link :to="category.path" v-for="category in category_list">
          <img class="normal" src="@/assets/menub.png" alt="" />
          <img class="active" src="@/assets/menubg-active.png" alt="" />
          <span>{{category.name}}</span>
        </router-link>
      </div>
    </div>
    <router-view />
  </div>
</template>
<script>
import { mapState, mapMutations } from "vuex";
export default {
  name: "indexView",
  data() {
    return {
      task_list:[],
      category_list:[],
    };
  },
  computed: {
    ...mapState(["task_id", "left_id"]),
  },
  mounted(){
    this.get_config();
  },
  methods: {
    ...mapMutations(["changeTaskId", "changeLeftId"]),
    change(id) {
      this.$store.commit("changeTaskId", id);
    },
    get_config() {
      this.$post("/index/config").then((res) => {
        this.task_list = res.data.task_list
        this.category_list = res.data.category_list
        this.$store.commit("changeTaskId", this.task_list[0].id);
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.headBox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100px;
  position: relative;
  .hearbg {
    position: absolute;
    right: 0;
    top: 0;
    height: 88px;
    width: 1515px;
  }
  .logobg {
    position: absolute;
    left: 0;
    top: 0;
  }
  .logo {
    position: relative;
    height: 58px;
    margin-left: 40px;
  }
  .task {
    padding: 0 60px;
    display: flex;

    span {
      display: block;
      padding: 0 50px;
      font-size: 24px;
      line-height: 48px;
      cursor: pointer;
      color: #72e6ff;
      font-weight: bold;
      position: relative;
      img {
        position: absolute;
        left: 50%;
        bottom: -22px;
        transform: translateX(-50%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
      }
    }
    .active {
      color: #fff;
      img {
        opacity: 1;
        visibility: visible;
      }
    }
  }
}
.menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  padding-top: 37px;
  div {
    display: flex;
  }
  a {
    color: #72e6ff;
    font-weight: bold;
    text-decoration: none;
    display: block;
    position: relative;
    font-size: 20px;
    margin-left: 20px;
    span {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      display: block;
      width: 100%;
      text-align: center;
    }
    .active {
      display: none;
    }
    .normal {
      display: block;
    }
  }
  .router-link-active {
    color: #fff;
    .active {
      display: block;
    }
    .normal {
      display: none;
    }
  }
}
</style>
